/*
package cn.itcast.dao;

import cn.itcast.pojo.Emp;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@Component
public class ConsumerDao {
    @Autowired
    private RestTemplate restTemplate;

    private static final Logger logger = LoggerFactory.getLogger(ConsumerDao.class);

    @HystrixCommand(fallbackMethod = "queryUserByIdFallback")
    public Emp queryUserById(int id) {
        long begin = System.currentTimeMillis();
        String url = "http://user-service/emp/"+id;
        long end = System.currentTimeMillis();
        // 记录访问用时：
        logger.info("访问用时：{}", end - begin);
        return restTemplate.getForObject(url,Emp.class);
    }

    public Emp queryUserByIdFallback(int id){
        Emp emp = new Emp();
        emp.setId(id);
        emp.setUsername("用户信息查询异常");
        return emp;
    }
}
*/
